//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CPolygon {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CPolygon(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CPolygon obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CPolygon(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setVertices(SWIGTYPE_p_std__vectorT_CVector_t value) {
    nelmiscJNI.CPolygon_Vertices_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_CVector_t.getCPtr(value));
  }

  public SWIGTYPE_p_std__vectorT_CVector_t getVertices() {
    long cPtr = nelmiscJNI.CPolygon_Vertices_get(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_CVector_t(cPtr, false);
  }

  public CPolygon() {
    this(nelmiscJNI.new_CPolygon__SWIG_0(), true);
  }

  public CPolygon(CVector a, CVector b, CVector c) {
    this(nelmiscJNI.new_CPolygon__SWIG_1(CVector.getCPtr(a), a, CVector.getCPtr(b), b, CVector.getCPtr(c), c), true);
  }

  public int getNumVertices() {
    return nelmiscJNI.CPolygon_getNumVertices(swigCPtr, this);
  }

  public void toTriFan(SWIGTYPE_p_std__vectorT_NLMISC__CTriangle_t dest) {
    nelmiscJNI.CPolygon_toTriFan(swigCPtr, this, SWIGTYPE_p_std__vectorT_NLMISC__CTriangle_t.getCPtr(dest));
  }

  public void clip(CPlane planes, long nPlanes) {
    nelmiscJNI.CPolygon_clip__SWIG_0(swigCPtr, this, CPlane.getCPtr(planes), planes, nPlanes);
  }

  public void clip(SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t planes) {
    nelmiscJNI.CPolygon_clip__SWIG_1(swigCPtr, this, SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t.getCPtr(planes));
  }

  public float computeArea() {
    return nelmiscJNI.CPolygon_computeArea(swigCPtr, this);
  }

  public void serial(IStream f) {
    nelmiscJNI.CPolygon_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public boolean toConvexPolygons(SWIGTYPE_p_std__listT_NLMISC__CPolygon_t outputPolygons, CMatrix basis) {
    return nelmiscJNI.CPolygon_toConvexPolygons(swigCPtr, this, SWIGTYPE_p_std__listT_NLMISC__CPolygon_t.getCPtr(outputPolygons), CMatrix.getCPtr(basis), basis);
  }

  public boolean chain(SWIGTYPE_p_std__vectorT_NLMISC__CPolygon_t other, CMatrix basis) {
    return nelmiscJNI.CPolygon_chain(swigCPtr, this, SWIGTYPE_p_std__vectorT_NLMISC__CPolygon_t.getCPtr(other), CMatrix.getCPtr(basis), basis);
  }

  public void getBestTriplet(SWIGTYPE_p_unsigned_int index0, SWIGTYPE_p_unsigned_int index1, SWIGTYPE_p_unsigned_int index2) {
    nelmiscJNI.CPolygon_getBestTriplet(swigCPtr, this, SWIGTYPE_p_unsigned_int.getCPtr(index0), SWIGTYPE_p_unsigned_int.getCPtr(index1), SWIGTYPE_p_unsigned_int.getCPtr(index2));
  }

  public void buildBasis(CMatrix dest) {
    nelmiscJNI.CPolygon_buildBasis(swigCPtr, this, CMatrix.getCPtr(dest), dest);
  }

  public void toConvexPolygonsLocalAndBSP(SWIGTYPE_p_std__vectorT_CVector_t localVertices, SWIGTYPE_p_NLMISC__CBSPNode2v root, CMatrix basis) {
    nelmiscJNI.CPolygon_toConvexPolygonsLocalAndBSP(swigCPtr, this, SWIGTYPE_p_std__vectorT_CVector_t.getCPtr(localVertices), SWIGTYPE_p_NLMISC__CBSPNode2v.getCPtr(root), CMatrix.getCPtr(basis), basis);
  }

  public static boolean toConvexPolygonsEdgeIntersect(CVector2f a0, CVector2f a1, CVector2f b0, CVector2f b1) {
    return nelmiscJNI.CPolygon_toConvexPolygonsEdgeIntersect(CVector2f.getCPtr(a0), a0, CVector2f.getCPtr(a1), a1, CVector2f.getCPtr(b0), b0, CVector2f.getCPtr(b1), b1);
  }

  public static boolean toConvexPolygonsLeft(SWIGTYPE_p_std__vectorT_CVector_t vertex, long a, long b, long c) {
    return nelmiscJNI.CPolygon_toConvexPolygonsLeft(SWIGTYPE_p_std__vectorT_CVector_t.getCPtr(vertex), a, b, c);
  }

  public static boolean toConvexPolygonsLeftOn(SWIGTYPE_p_std__vectorT_CVector_t vertex, long a, long b, long c) {
    return nelmiscJNI.CPolygon_toConvexPolygonsLeftOn(SWIGTYPE_p_std__vectorT_CVector_t.getCPtr(vertex), a, b, c);
  }

  public static boolean toConvexPolygonsInCone(SWIGTYPE_p_std__vectorT_CVector_t vertex, long a, long b) {
    return nelmiscJNI.CPolygon_toConvexPolygonsInCone(SWIGTYPE_p_std__vectorT_CVector_t.getCPtr(vertex), a, b);
  }

  public static boolean toConvexPolygonsDiagonal(SWIGTYPE_p_std__vectorT_CVector_t vertex, SWIGTYPE_p_NLMISC__CBSPNode2v bsp, long a, long b) {
    return nelmiscJNI.CPolygon_toConvexPolygonsDiagonal(SWIGTYPE_p_std__vectorT_CVector_t.getCPtr(vertex), SWIGTYPE_p_NLMISC__CBSPNode2v.getCPtr(bsp), a, b);
  }

}
